//
//  LocationAlertControlViewController.m
//  OCUI
//
//  Created by bus365-03 on 15/10/28.
//
//

#import "LocationAlertControlViewController.h"
#import <CoreLocation/CoreLocation.h>
@interface LocationAlertControlViewController ()

@end

@implementation LocationAlertControlViewController
 CLLocationManager *myLocationManager;//位置管理
typedef enum AlertTag
{
    ServicesEnabled=1234,
    RequestLocation,
    CurrentCity,
    
}AlertTag;
- (void)viewDidLoad {
    [super viewDidLoad];
    
    if (![CLLocationManager locationServicesEnabled]) {
        UIAlertView *locationAlert=[[UIAlertView alloc]initWithTitle:@"消息提示" message:@"请到设置中心去设置开启定位服务" delegate:self cancelButtonTitle:nil otherButtonTitles:@"ok", nil];
        [locationAlert show];
    }
    // Do any additional setup after loading the view.
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    //检查弹出框的点击按钮是哪一个
    NSLog(@"alertView tag %ld buttonIndex %ld",(long)alertView.tag,(long)buttonIndex);
    AlertTag alertTag=(int)alertView.tag;
    switch (alertTag) {
        case ServicesEnabled: {
            [[UIApplication sharedApplication]openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
            break;
        }
        case RequestLocation: {
            if (buttonIndex!=0) {
               
            }
            break;
        }
        case CurrentCity:
        {
            
            
        }
        default: {
            break;
        }
    }
    
}
- (void)initLocationManager
{
    if (myLocationManager) {
        myLocationManager=nil;
        myLocationManager.delegate=nil;
    }
    myLocationManager=[[CLLocationManager alloc]init];
    myLocationManager.desiredAccuracy=kCLLocationAccuracyBest;
    myLocationManager.delegate=self;
    if ([[[UIDevice currentDevice] systemVersion]floatValue]>=8.0) {
        [myLocationManager requestAlwaysAuthorization];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
